package logic

import (
	"context"
	"user_srv/userclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type NovelListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewNovelListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NovelListLogic {
	return &NovelListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *NovelListLogic) NovelList(req *types.NovelListRquest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	name, err := l.svcCtx.UserRpc.NovelList(l.ctx, &userclient.NovelListRequest{})
	if err != nil {
		return &types.Response{
			Mes:  err.Error(),
			Code: 400,
			Data: name,
		}, nil
	}
	return &types.Response{
		Mes:  "小说列表展示成功",
		Code: 200,
		Data: name,
	}, nil
}
